Skip to content

feat(gateway): a class or range request is served by a worker that fits - #357

Merged
V3RON merged 3 commits into
mainfrom
task/336
Oct 5, 2026
Merged

V3RON merged 3 commits into
mainfrom
task/336

Conversation

@V3RON

@V3RON V3RON commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #336

Status

Implement: done (40/40 green) Review: round 1, 0 open Mutate: 5 alive (equivalent) Hardware: n/a Gate: merged

Done when

  • Every test in the spec passes and pnpm check is green.
  • The gateway e2e suites pass, and no test asserts the two stubs (the stubs and their dispatcher tests are removed; the dispatcher now has tests that a class, neither, and a range are forwarded as they arrived).
  • Every completion condition of A lease request can leave the model open or name a device class #326 is walked below (this is the last task).

Completion conditions of #326

Conditions about a single worker are proved by the tests of #332 to #335, which this PR does not touch (e2e/lease-lifecycle.test.ts, src/core/*). The gateway-facing ones:

  1. lease --platform ios with no class: served through a gateway, forwarded with no model/class (fleet-coordinator.test.ts "forwards a request naming neither model nor class with neither"; dispatcher %s table); a worker grants the phone (single worker: lease-lifecycle.test.ts).
  2. Warm iPhone 15, --class phone: warm-hit.test.ts "counts a ready device of another model in the requested class as warm". An exact request still needs the exact model (same file, exact cases).
  3. Warm Apple Watch, no class vs --class watch: same test, iPad Pro (tablet) is not warm for phone and is for tablet.
  4. --os '>=18', --os '<=17': request-match.test.ts (range matches / does not), serviceability.test.ts row 4 "with the range as typed", e2e gateway-fast-fail RUNTIME_MISSING with and without --allow-download, e2e gateway-fleet --os '>=18' lands on the worker whose runtime is in range. ^18 is refused by the contract before the gateway (--os accepts a version range #335).
  5. Mode and image tag never relaxed: warm-hit.test.ts "does not count a device in a mode the request refuses as warm" and "another image tag"; request-match.test.ts "counts only runtimes with an image of the tag for a class request".
  6. Creation on the newest runtime / preference list / UNKNOWN_MODEL naming the config key: a worker decision, forwarded untouched (The catalog shows the default model per class, from config over built-in lists #333, A request names a class or nothing, and is served by a fitting idle device before a new one #334). Through a gateway, UNKNOWN_MODEL for a class no worker lists names the key too (serviceability.test.ts).
  7. --class with --device is BAD_REQUEST: refused by the contract schema before the gateway.
  8. Through a gateway, warm Pixel on one worker and room on another: fleet-coordinator.test.ts "dispatches an Android phone request to the worker with a warm Pixel over one with free capacity" and e2e gateway-fleet "grants an Android --class phone request on the worker holding a warm Pixel" (the grant is the warm device, nothing provisioned on the other worker). A request with room that no worker can serve fails at once: e2e gateway-fast-fail "fails a class or range request nothing in the fleet can serve at once".
  9. simlock catalog classes and defaults: The catalog names each model's class #332/The catalog shows the default model per class, from config over built-in lists #333, unchanged here.
  10. MCP and HTTP accept the same fields: unchanged here; both reach the gateway dispatcher this PR opens.
  11. Every exact request behaves the same: the existing gateway suites (routing, coordinator, dispatcher, e2e) pass unchanged; an exact model is still forwarded under the worker's own name.
  12. Docs: docs/CLI.md, docs/HTTP-API.md, docs/CLIENT.md drop "for now" and describe gateway matching of a class and a range; docs/internal/ARCHITECTURE.md routing section updated; both EVENTS.md rows for request.dispatched carry model?/class? under the ADR 0015 §9 exception.

Equivalent mutants

  • fleet-coordinator.ts routable() model/class spread: { model: undefined } reads the same as an absent key.
  • fleet-coordinator.ts forwardedModel: the view of a picked worker always exists in the list it came from.
  • request-match.ts [] for "no device fits": any other array of versions matches no device either.
  • warm-hit.ts deviceSpec: { imageTag: undefined } and an absent key compare equal in fits.

Assumptions

  • Assumption: the UNKNOWN_MODEL message for a class request — it names <platform>.defaultModels.<class> and says "on a worker", as the worker's own message names the key; the details carry class, no model.
  • Assumption: src/gateway/boundary.test.ts allows core/catalog-match.js — architecture rule 10 has the gateway import findCatalogModel from it, and the file is pure functions.
  • Assumption: request.dispatched class is typed string in src/bus/index.ts, as the bus imports no core types.

Review

Spec review: 0 blocking, 0 fixed, 2 notes. Code review: 0 blocking, 0 fixed, 0 notes.
Mutate: 131 mutants, 5 alive.

Written by an agent.

@V3RON

V3RON commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

Review notes

Not blocking, not verified. Each is one reviewer's claim.

  • spec: issue.md:52 the Done when line "The PR body walks every completion condition of A lease request can leave the model open or name a device class #326" cannot be checked from the diff; the PR body is not in it (the body walks all twelve conditions).
  • spec (rejected after checking): exact --os versions now go through satisfies/fits, so --os 18 could reach a worker listing only 18.0. Wrong: satisfies on an exact constraint is string equality (src/contract/os-range.ts:114).

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 5, 2026 16:46
@V3RON
V3RON merged commit 4ab8641 into main Oct 5, 2026
35 of 36 checks passed
@V3RON
V3RON deleted the task/336 branch November 6, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Through a gateway, a class or range request is served by a worker that fits

1 participant